package com.fx.jhr.service.impl;

import com.fx.jhr.domain.XsJhr;
import com.fx.jhr.mapper.XsJhrMapper;
import com.fx.jhr.service.IXsJhrService;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 学生监护人Service业务层处理
 *
 * @author fxiao
 * @date 2021-08-05
 */
@Service
public class XsJhrServiceImpl implements IXsJhrService
{
    @Autowired
    private XsJhrMapper xsJhrMapper;

    /**
     * 查询学生监护人
     *
     * @param id 学生监护人ID
     * @return 学生监护人
     */
    @Override
    public XsJhr selectXsJhrById(Long id)
    {
        return xsJhrMapper.selectXsJhrById(id);
    }

    /**
     * 查询学生监护人列表
     *
     * @param xsJhr 学生监护人
     * @return 学生监护人
     */
    @Override
    public List<XsJhr> selectXsJhrList(XsJhr xsJhr)
    {
        return xsJhrMapper.selectXsJhrList(xsJhr);
    }

    /**
     * 新增学生监护人
     *
     * @param xsJhr 学生监护人
     * @return 结果
     */
    @Override
    public int insertXsJhr(XsJhr xsJhr)
    {
        xsJhr.setCreateTime(DateUtils.getNowDate());
        xsJhr.setCreateBy(SecurityUtils.getUsername());
        return xsJhrMapper.insertXsJhr(xsJhr);
    }

    /**
     * 修改学生监护人
     *
     * @param xsJhr 学生监护人
     * @return 结果
     */
    @Override
    public int updateXsJhr(XsJhr xsJhr)
    {
        xsJhr.setUpdateTime(DateUtils.getNowDate());
        xsJhr.setCreateBy(SecurityUtils.getUsername());
        return xsJhrMapper.updateXsJhr(xsJhr);
    }

    /**
     * 批量删除学生监护人
     *
     * @param ids 需要删除的学生监护人ID
     * @return 结果
     */
    @Override
    public int deleteXsJhrByIds(Long[] ids)
    {
        return xsJhrMapper.deleteXsJhrByIds(ids);
    }

    /**
     * 删除学生监护人信息
     *
     * @param id 学生监护人ID
     * @return 结果
     */
    @Override
    public int deleteXsJhrById(Long id)
    {
        return xsJhrMapper.deleteXsJhrById(id);
    }

    @Override
    public int deleteByStudent(Long[] studentIds) {
        return xsJhrMapper.deleteByStudent(studentIds);
    }

    @Override
    public List<XsJhr> selectByStudent(Long studentid) {
        return xsJhrMapper.selectByStudent(studentid);
    }
}
